#include "data.h"

Data::Data(QObject *parent) : QObject(parent)
{
    Mysql_data();
}

void Data::Mysql_data()
{
    db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("localhost");
    db.setPort(3306);
    db.setDatabaseName("server_data");
    db.setUserName("root");
    db.setPassword("123456");
    if (!db.open()) {
        qDebug("mysql connect failed.");
    } else {
        qDebug("mysql connected.");
    }
}
